const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2')
const Schema = mongoose.Schema

let OrderSchema = new Schema({
  orderNo: String,
  opCode: String,
  opName: String,
  orderState: {
    type: String,
    default: '订单已提交'
  },
  totalCount: Number,
  totalMoney: Number,
  generateTime: { type: Date, default: Date.now },
  stores: [{
    storeId: String,
    storeName: String,
    totalCount: Number,
    totalMoney: Number,
    products: [{
      sku: String,
      title: String,
      price: Number,
      totalCount: Number,
      totalMoney: Number,
      category: String,
      season: String,
      thumbnail: String,
      colors: [ String ],
      sizes: [{
        label: String,
        colors: [ Number ]
      }]
    }]
  }]
})

OrderSchema.plugin(mongoosePaginate)

// Export the model
module.exports = mongoose.model('Order', OrderSchema)